home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
SCIENTIF
/
0428.ZIP
/
NMR6.BAS
< prev
next >
Wrap
BASIC Source File
|
1985-04-19
|
7KB
|
187 lines
1 'NMR6--Part 6 of NMRCALC package. Energy level diagrams.
10 DEFINT I-N
20 'COMMON IPFLAG,IREAD,FF$
21 OPEN "scratch.nmr" FOR INPUT AS 1
22 INPUT #1, IPFLAG: INPUT #1, IREAD: LINE INPUT #1, FF$
23 CLOSE #1
30 DIM E(128), FZ(128), SINT(3003), BC(7), ILOW(3003), IHIGH(3003), IX(128), IY(128), ILEN(7)
40 FOR I = 1 TO 7: READ ILEN(I): NEXT
45 DATA 160,80,53,27,16,8,5
50 SCREEN 0,0,0: COLOR 14,4,1: KEY OFF: CLS
60 PRINT:PRINT"Routine to generate energy level (and Fz-level) diagrams.": PRINT:PRINT"To return from plot, hit any key after plot completed.":PRINT
65 GOSUB 63999
70 ON ERROR GOTO 60000
80 ILINE = 0: TH1 = 0: TH2 = 0
90 YRANGE = 160: YTOP = (200 - YRANGE)/2
95 IF IREAD > 0 THEN GOSUB 5030
100 SCREEN 0,0,0: COLOR 14,4,1: CLS: PRINT: PRINT"Enter command ('ME' for menu): ";: GOSUB 500
110 IF P$ = "EN" THEN GOSUB 1000
120 IF P$ = "FZ" THEN GOSUB 2000
130 IF P$ = "ME" THEN GOSUB 3000
140 IF P$ = "TR" THEN GOSUB 6000
150 IF P$ = "QL" THEN GOSUB 900: CHAIN "nmr4"
160 IF P$ = "QP" THEN GOSUB 900: CHAIN "nmr5"
170 IF P$ = "QM" THEN GOSUB 900: CHAIN "nmr1"
180 IF P$ = "QT" THEN PRINT:PRINT "End of run. Exiting to system.": END
190 IF P$ = "RD" THEN GOSUB 5000
200 IF P$ = "TH" THEN GOSUB 4000
210 IF P$ = "FF" THEN LPRINT CHR$(12);
300 GOTO 100
500 P1$ = INKEY$: IF P1$ = "" THEN 500
510 IF ASC(P1$) > 90 THEN P1$ = CHR$(ASC(P1$) - 32)
520 PRINT P1$;
530 P2$ = INKEY$: IF P2$ = "" THEN 530
540 IF ASC(P2$) > 90 THEN P2$ = CHR$(ASC(P2$) - 32)
550 PRINT P2$
560 P$ = P1$ + P2$
570 RETURN
600 P$ = INKEY$: IF P$ = "" THEN 600
610 IF ASC(P$) > 90 THEN P$ = CHR$(ASC(P$) - 32)
620 PRINT P$
630 RETURN
900 OPEN "scratch.nmr" FOR OUTPUT AS 1
910 PRINT #1, IPFLAG: PRINT #1, IREAD: PRINT #1, FF$
920 CLOSE 1
930 RETURN
1000 CLS: PRINT:PRINT"Energy level plotting mode selected. "
1010 GOSUB 63999
1030 ESCALE = YRANGE/(EMIN - EMAX)
1040 B = YTOP - ESCALE*EMAX
1050 FOR I = 1 TO NF
1060 IY(I) = ESCALE*E(I) + B
1070 NEXT
1080 IMODE = 1
1090 GOSUB 10000
1100 P$ = INKEY$: IF P$ = "" THEN 1100 ELSE RETURN
2000 CLS:PRINT:PRINT"Fz-level plotting mode selected."
2010 GOSUB 63999
2020 ESCALE = YRANGE/(FZMIN - FZMAX)
2030 B = YTOP - ESCALE*FZMAX
2040 FOR I = 1 TO NF
2050 IY(I) = ESCALE*FZ(I) + B
2060 NEXT
2070 IMODE = 2
2080 GOSUB 10000
2090 GOTO 1100
3000 CLS:PRINT:PRINT"Menu of available options: ":PRINT
3010 PRINT"EN--Do energy level plot."
3015 PRINT"FF--Form feed to printer (useful if printer plotting)."
3020 PRINT"FZ--Do Fz-level plot."
3030 PRINT"ME--Display this menu."
3050 PRINT"QL--Exit to line-listing routine (NMR4)."
3060 PRINT"QM--Exit to main program (NMR1)."
3070 PRINT"QP--Exit to plotting routine (NMR5)."
3080 PRINT"QT--Exit to main system (terminate execution)."
3090 PRINT"RD--Read in needed information from disk."
3100 PRINT"TH--Enter threshold options."
3120 PRINT"TR--Select transition drawing options."
3150 GOTO 63999
4000 CLS:PRINT:PRINT"Routine to select threshold selection options.":PRINT
4010 PRINT"The rules: 1) If both thresholds are zero, all lines plotted."
4020 PRINT" 2) THRESHOLD1 sets the minimum line intensity."
4030 PRINT" 3) THRESHOLD2 sets the maximum line intensity."
4040 PRINT" (Default: THRESHOLD2 = 1.00001)"
4050 PRINT:PRINT
4060 INPUT"Enter THRESHOLD1: ",TH1
4070 INPUT"Enter THRESHOLD2: ",TH2
4075 IF TH1 = 0 AND TH2 = 0 THEN 63999
4080 IF TH1 >= 0 AND TH2 = 0 THEN TH2 = 1.00001
4090 IF TH1 > TH2 THEN BEEP: PRINT: GOTO 4050
4100 GOTO 63999
5000 CLS:PRINT:PRINT"Ready for relevant information from the disk.":PRINT: PRINT"Do you need to specify the data set name? ";: GOSUB 600
5010 IF P$ = "N" THEN 5030 ELSE IF P$ <> "Y" THEN 5000
5020 PRINT: INPUT"Enter data set name: ",FF$
5030 PRINT: PRINT "Now reading in needed information.":PRINT
5040 DF$ = FF$ + ".inf": PRINT: PRINT"Reading in file ";DF$
5050 OPEN DF$ FOR INPUT AS 1
5060 INPUT #1, NS
5070 INPUT #1, NF
5080 FOR I = 0 TO NS: INPUT #1, BC(I): NEXT
5090 CLOSE 1
5100 FZ = NS/2 + 1: K = 0
5110 FOR I = 1 TO NS + 1
5120 FZ = FZ - 1
5130 FOR J = 1 TO BC(I-1)
5140 K = K + 1: FZ(K) = FZ
5150 NEXT
5160 NEXT
5170 K = 0
5180 FOR I = 1 TO NS + 1
5190 DF$ = FF$ + "." + RIGHT$(STR$(I), LEN(STR$(I)) - 1)
5200 PRINT"Reading in file ";DF$
5210 OPEN DF$ FOR INPUT AS #1
5220 INPUT #1, N
5230 FOR J = 1 TO N
5240 K = K + 1
5250 INPUT #1, E(K)
5260 NEXT
5270 CLOSE #1
5280 NEXT
5290 EMIN = 1E+20: EMAX = -1E+20
5300 FOR I = 1 TO NF
5310 EI = E(I)
5320 IF EI > EMAX THEN EMAX = EI: GOTO 5340
5330 IF EI < EMIN THEN EMIN = EI
5340 NEXT
5350 FZMAX = FZ(1): FZMIN = FZ(NF)
5360 NL = 0
5370 FOR I = 1 TO NS: NL = NL + BC(I-1)*BC(I): NEXT
5380 DF$ = FF$ + ".lin"
5390 OPEN DF$ FOR INPUT AS 1: PRINT"Reading in file ";DF$
5400 FOR I = 1 TO NL
5410 INPUT #1, SLINE#
5420 SM = 1000*(SLINE# - INT(SLINE#)): SL = INT(SLINE#): SM = INT(SM + .1)
5430 ILOW(I) = SM: IHIGH(I) = SL
5440 INPUT #1, JUNK#
5450 INPUT #1, SINTIN#: SINT(I) = SINTIN#
5460 NEXT
5470 CLOSE 1
5475 K = 0
5480 FOR I = 1 TO NS + 1
5490 N = BC(I-1): XINCR = 640/(N + 1)
5500 FOR J = 1 TO N
5510 K = K + 1
5520 IX(K) = J*XINCR
5530 NEXT
5540 NEXT
5550 PRINT:PRINT"Preliminary reading finished.": GOTO 63999
6000 CLS:PRINT:PRINT"Routine to select transition-plotting option.":PRINT
6010 PRINT"This option is currently ";
6020 IF ILINE = 0 THEN PRINT "OFF" ELSE PRINT "ON"
6030 PRINT:PRINT"Change option? ";: GOSUB 600
6040 IF P$ = "N" THEN 63999
6050 IF P$ <> "Y" THEN BEEP: GOTO 6030
6060 IF ILINE = 0 THEN ILINE = 1 ELSE ILINE = 0
6070 GOTO 63999
10000 SCREEN 0: SCREEN 2: OUT 985,14: LINE (0,0)-(639,199),,B: IB = B
10002 LOCATE 2,2
10004 IF IMODE = 1 THEN PRINT"Energy level diagram--";
10006 IF IMODE = 2 THEN PRINT"Fz-level diagram--";
10010 FOR I = 0 TO 639
10020 IF I MOD 8 = 0 THEN PSET (I,IB)
10030 NEXT
10040 IL = ILEN(NS)
10050 FOR I = 1 TO NF
10060 IXI = IX(I): IYI = IY(I)
10070 LINE (IXI - IL, IYI) - (IXI + IL, IYI)
10080 NEXT
10085 IF ILINE = 0 THEN RETURN
10090 LOCATE 24,2
10100 IF TH1 = 0 AND TH2 = 0 THEN PRINT "All lines plotted.";: GOTO 10150
10110 PRINT"Intensity range:";
10120 PRINT USING "##.#####"; TH1;
10130 PRINT " - ";
10140 PRINT USING "##.#####"; TH2;
10150 FOR I = 1 TO NL
10160 SI = SINT(I)
10165 IF TH2 = 0 THEN 10180
10170 IF SI < TH1 OR SI > TH2 THEN 10200
10180 IA = ILOW(I): IB = IHIGH(I)
10190 LINE (IX(IA), IY(IA)) - (IX(IB), IY(IB))
10200 NEXT
10210 RETURN
60000 CLS:PRINT:PRINT"Error encountered! Did you read in all needed files?"
60010 GOSUB 63999
60020 RESUME 100
63999 IF IPFLAG = 1 THEN RETURN ELSE PRINT: INPUT"Hit <Return> to continue.",A$: RETURN